import { onMounted, ref } from "vue";

export type IGdp = {
  country: string;
  value: number;
};

export default function useFetchIGdp() {
  const gdp = ref<IGdp[]>([]);

  const fetchData = async () => {
    gdp.value = await fetch("/api/gdp.json").then((resp) => resp.json());
  };

  onMounted(() => {
    fetchData();
  });

  return {
    gdp,
    fetchData,
  };
}
